local skel = fk.CreateSkill {
  name = "emo__tongshou",
  tags = {Skill.Compulsory},
}

Fk:loadTranslationTable{
  ["emo__tongshou"] = "同寿",
  [":emo__tongshou"] = "锁定技，第二、四、八轮开始时，你将体力上限和体力值调整至X（X为存活角色数）。",
}

skel:addEffect(fk.RoundStart, {
  anim_type = "defensive",
  can_trigger = function(self, event, target, player, data)
    local count = player.room:getBanner("RoundCount")
    return player:hasSkill(skel.name) and (count == 2 or count == 4 or count == 8)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local x = #room.alive_players
    local y = x - player.maxHp
    if y ~= 0 then
      room:changeMaxHp(player, y)
      if player.dead then return end
    end
    y = x - player.hp
    if y > 0 then
      room:recover { num = y, skillName = self.name, who = player, recoverBy = player}
    elseif y < 0 then
      room:loseHp(player, -y, self.name)
    end
  end,
})

return skel
